package com.example.demo.service;

import com.example.demo.dao.SysUserRepository;
import com.example.demo.entity.SysUserVo;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 
 * Description:账户详情信息
 * @author huangweicheng
 * @date 2019/10/21   
*/ 
@Service
public class SysUserDetailsServiceImpl implements UserDetailsService
{
    @Resource
    private SysUserRepository sysUserRepository;

    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException
    {
        SysUserVo sysUser = sysUserRepository.findByUserName(userName);
        if (sysUser == null)
        {
            throw new UsernameNotFoundException(userName);
        }
        return sysUser;
    }
}